<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>用*构成菱形图案</title>
</head>
    <body>
<%

    StringBuffer sb = new StringBuffer();
    int n = 6;
    //输出前n行
    for (int i = 1; i <= n; i++) {
        //输出空格
        for (int k = 1; k <= n - i; k++) {
            sb.append("&nbsp");
        }
        //输出*号
        for (int j = 1; j <= i; j++) {
            sb.append("*");
        }
        sb.append("<br>");
    }
    //输出后n-1行
    for (int i = n - 1; i > 0; i--) {
        //输出空格
        for (int k = 1; k <= n - i; k++) {
            sb.append("&nbsp");
        }
        //输出*号
        for (int j = 1; j <= i; j++) {
            sb.append("*");
        }
        sb.append("<br>");
    }

%>
<%= sb.toString() %>
    </body>
</html>

